package com.zjdiepu.www.commpent.mapper.third;

import java.text.ParseException;
import java.text.SimpleDateFormat;

import javax.annotation.Resource;

import org.apache.commons.lang.StringUtils;
import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.stereotype.Component;

import com.zjdiepu.www.base.core.BaseMapper;
import com.zjdiepu.www.common.util.DateUtil;
import com.zjdiepu.www.commpent.RedisObjectClient;
import com.zjdiepu.www.model.third.dto.AliDeliverInfoDetail;
/**
 * 项目名称：dpqc-parent-manager-information <br/> 
 * 类名称：AliDeliverInfoDetailViewMapper <br/>  
 * 类描述： 运单详情<br/>    
 * 创建人：xiongxiaotun <br/> 
 * 创建时间：2017年4月26日 下午1:33:37  <br/>   
 * 修改人：xiongxiaotun <br/> 
 * 修改时间：2017年4月26日 下午1:33:37   <br/>  
 * 修改备注：    <br/> 
 * @version V1.0   <br/>
 */
@Component
public class AliDeliverInfoDetailViewMapper extends BaseMapper<AliDeliverInfoDetail>{

	@Resource
	private RedisObjectClient redisObjectClient;
	private final static SimpleDateFormat SIMPLE_DATE_FORMAT= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	@Override
	public void mapper(RedisConnection redisConnection,AliDeliverInfoDetail m) {
		if(null == m) {
			return;
		}
		
		String time = m.getTime();
		if(StringUtils.isNotBlank(time)) {
			try {
				String weekOfDate = DateUtil.getWeekOfDate(SIMPLE_DATE_FORMAT.parse(time));
				m.setWeek(weekOfDate);
			} catch (ParseException e) {
				m.setTime("时间缺失");
				m.setWeek("-");
			}
		} else {
			m.setTime("时间缺失");
			m.setWeek("-");
		}
		
	}

}
